using System;
using System.IO;
using System.Reflection;

namespace Cz
{
    public static class CzAssemblyTool
    {
        public static void CreateFile(this Assembly assembly, string filePath, string resourceName)
        {
            // // 取得該 DLL 所有的內嵌資源名稱
            // var resources = assembly.GetManifestResourceNames();
            // Console.WriteLine("resources:" + resources.ToJson());
            
            // 如果日志文件不存在,则从模板创建一个
            if (!File.Exists(filePath))
            {
                using (var sourceStream = assembly.GetManifestResourceStream(resourceName))
                using (var toStream = File.Create(filePath))
                {
                    sourceStream.CopyTo(toStream);
                    toStream.Flush();
                }
            }
        }
    }
}